<script>
function UpdateFormFlow(sURLAppend) {
	document.Browse.action=document.Browse.action + "&grproute= "
	document.Browse.submit()
}
function checkSelected(){
	var max = Browse.chkAction.length;
	for (var idx = 0; idx < max; idx++) {
	if (eval("document.Browse.chkAction[" + idx + "].checked") == true) {
	    	document.Browse.btnGrpRoute.disabled = false;
		break;
		}
	else{
		document.Browse.btnGrpRoute.disabled = true;
	   }
	
	}
}
</script>
<CFSETTING ENABLECFOUTPUTONLY="Yes">
<!--- get records for the eform for browsing --->
<CFSET sRecFilter = "">
<CFIF len(trim(GetForm.RECORDFILTER)) NEQ 0>
<CFIF eform.char EQ "all">
	<CFSET sRecFilter = " WHERE ">
<CFELSE>
	<CFSET sRecFilter = " AND ">
</CFIF>
<CFIF lcase(left(GetForm.RECORDFILTER, 4)) EQ "self">
	<CFSET sRecFilter = sRecFilter & GetForm.PK_FIELD1 & "='" & client.chapa & "' " & mid(GetForm.RECORDFILTER, 5, len(GetForm.RECORDFILTER)-4)>
<CFELSE>
	<CFSET sRecFilter = sRecFilter & GetForm.RECORDFILTER>
</CFIF>
</CFIF>

<CFSET lWithWhere=false>
<CFQUERY NAME="GetData" DATASOURCE="#table_dsn#">
	SELECT *
	FROM #eform.tablename#
	<CFIF trim(eform.locator) NEQ "">
		WHERE (#eform.field# LIKE '%#eform.locator#%') #PreserveSingleQuotes(sRecFilter)#
		<CFSET lWithWhere=true>
		<CFELSE>
			<CFSET lWithWhere=true>

		<CFIF eform.char EQ "all">
			#PreserveSingleQuotes(sRecFilter)#
			<CFIF sRecFilter IS "">
				<CFSET lWithWhere=false>
			</CFIF>
		<CFELSEIF eform.char EQ "">
			WHERE (#eform.field# IS NULL) #PreserveSingleQuotes(sRecFilter)#
		<CFELSE>
			WHERE (#eform.field# LIKE '#eform.char#%') #PreserveSingleQuotes(sRecFilter)#
		</CFIF>
	</CFIF>

	<CFIF lWithWhere>
		AND (PERSONNELIDNO       = '#GetEmployee.PERSONNELIDNO#') AND ((ROUTEID IS NULL OR  ROUTEID = '') OR APPROVED = 'R')
	<CFELSE>
		WHERE (PERSONNELIDNO       = '#GetEmployee.PERSONNELIDNO#') AND ((ROUTEID IS NULL OR  ROUTEID = '') OR APPROVED = 'R')
	</CFIF>
	ORDER BY #eform.field# #eform.ascdesc#
</CFQUERY>


<CFSET sUrlFields = "">
<CFLOOP INDEX="x" FROM="1" TO="5">
	<CFSET strPk_Field = evaluate("GetForm.PK_FIELD" & x)>
	<CFIF strPk_Field NEQ "" AND listFindNoCase(sUrlFields,strPk_Field) EQ 0>
		<CFSET sUrlFields = listAppend(sUrlFields,strPk_Field)>
	</CFIF>
</CFLOOP>
<CFLOOP QUERY="GetFormDetails">
	<CFLOOP INDEX="x" FROM="1" TO="5">
		<CFSET strLnk_Field = evaluate("GetFormDetails.LNK_FIELD" & x)>
		<CFIF strLnk_Field NEQ "" AND listFindNoCase(sUrlFields,strLnk_Field) EQ 0>
			<CFSET sUrlFields = listAppend(sUrlFields,strLnk_Field)>
		</CFIF>
	</CFLOOP>
</CFLOOP>
<!--- Get URL fields End--->
<CFSET client.sUFValue = "">
<CFLOOP QUERY="GetData"><!--- get the values of the indexed fields --->
	<CFSET FIRST=TRUE>
	<CFIF client.sUFValue NEQ "">
		<CFSET client.sUFValue = client.sUFValue & "|">
	</CFIF>
		<CFLOOP LIST="#sUrlFields#" INDEX="x">
			<CFIF x NEQ "PERSONNELIDNO">
				<CFIF FIRST>
					<CFSET client.sUFValue = client.sUFValue  & x & "='" & evaluate("GetData." & x) & "'">
				<CFELSE>
					<CFSET client.sUFValue = client.sUFValue & "~" & x & "='" & evaluate("GetData." & x) & "'">
				</CFIF>
				<CFSET FIRST=FALSE>
			</CFIF>
		</CFLOOP>
</CFLOOP>

<CFSETTING ENABLECFOUTPUTONLY="No">
<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Form-Flow Related Information" SHOW="True">
<CFLOOP QUERY ="GETDATA">
	<!--- no data-flow if eforms doesnt have processcode attached in it and eforms table doesnt have routeid --->
	<CFSET lHasUserRole="No">
	<CFSET sPrevRcpt=client.chapa>


	<CFQUERY NAME="GetActs" DATASOURCE="#client.company_dsn#">
		SELECT *
		FROM CINFFACTIVITY
		WHERE
		<CFIF ISDEFINED("CLIENT.newformflow")>
			(PROCESSCODE = '#CLIENT.newformflow#')
		<CFELSE>
			(PROCESSCODE = '#GetForm.PROCESSCODE#')
		</CFIF>
		ORDER BY ORDERID, DESCRIPTION
	</CFQUERY>

	<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">
		<!--- extract initialization process --->
		<CFQUERY NAME="GetInit" DATASOURCE="#client.company_dsn#">
			SELECT D.*, M.ORIGINATOR
			FROM CRGROUTEDETAILS D, CRGROUTEMAIN M
			WHERE
				(M.ROUTEID = D.ROUTEID) AND
				(D.ROUTEID = '#GETDATA.ROUTEID#') AND
				(D.ORDERID = '1')
		</CFQUERY>
		<CFQUERY NAME="qryGetTime" DATASOURCE="#client.company_dsn#">
			SELECT TIMELASTUPDATE
			FROM CRGROUTEDETAILS
			WHERE (ROUTEID = '#GETDATA.ROUTEID#') AND (STATUS = 'STARTED')
		</CFQUERY>
</CFLOOP>
		<TR>
			<TD COLSPAN=3 CLASS="bold">
				<CFIF GetInit.RecordCount>
					<CFOUTPUT>
					<BR>
					This form has been routed by&nbsp;<U>#GetInit.ORIGINATOR#</U>&nbsp;last&nbsp;
					<U>#DayOfWeekAsString(DayOfWeek(GetInit.DATELASTUPDATE))#,&nbsp;
					#DateFormat(GetInit.DATELASTUPDATE, "mmmm d, yyyy")#</U>&nbsp;at&nbsp;
					<!---<U>#TimeFormat(GetInit.DATELASTUPDATE, "hh:mmtt")#</U>.<BR>--->
					<U>#qryGetTime.TIMELASTUPDATE#</U>.<BR>
					</CFOUTPUT>
					<!--- Added by Mhel --->
					<!--- Start --->
					<CFSET lIsRouted="Yes">
					<!--- End --->
				<CFELSE>
					<BR>
					This form has NOT been routed.<BR>
					<!--- Added by Mhel --->
					<!--- Start --->
					<CFSET lIsRouted="No">
					<!--- End --->
				</CFIF>
				<CFIF #lcase(GETDATA.APPROVED)# EQ "r">
					<CFSET lIsRouted="No">
				</CFIF>
				<HR>
			</TD>
		</TR>
		<CFIF NOT GetActs.RecordCount>
			<TR>
				<TD COLSPAN=3 CLASS="bold11">
					<FONT COLOR="#FF0000">
					This form cannot be routed, the attached process is invalid.<br>
					Please contact your iBOS/e Administrator.
					</FONT>
				</TD>
			</TR>
			<CFSET lValidRoute  = False>
		</CFIF>

		<CFOUTPUT QUERY="GetActs">
		<TR VALIGN="top">
			<TD WIDTH="50%">
				<CFSETTING ENABLECFOUTPUTONLY="Yes">

				<!--- ************************************************************* --->
				<!--- ************************************************************* --->
				<!--- ******    THE ROUTING PATH IS DEFINED AND EXTRACTED   ******* --->
				<!--- ******    THE PROCESS STARTS HERE                     ******* --->
				<!--- ************************************************************* --->
				<!--- ************************************************************* --->

				<CFSET lUserRole="No">
				<CFSET sIntentedRec  = "">
				<CFSWITCH EXPRESSION="#lcase(GetActs.MAPPING)#">

					<!--------------------------------------->
					<!--- the originator is the recipient --->
					<!--------------------------------------->
					<CFCASE VALUE="originator">
						<CFIF GetActs.CurrentRow EQ 1>
							<CFSET sIntentedRec = "<FONT COLOR=RED>Invalid! The originator cannot be the recipient of the first activity.</FONT>">
							<CFSET lValidRoute  = False>
						<CFELSE>
							<CFSET sIntentedRec = "(" & client.chapa & ") " & client.myname>
						</CFIF>

						<CFSET sPrevRcpt=client.chapa>
					</CFCASE>

					<!-------------------------------------------------->
					<!--- extract the recipient through the unitcode --->
					<!-------------------------------------------------->
					<CFCASE VALUE="userrole">
						<!--- get unitcode to use --->
						<CFSET sUnitCode2Use=Trim(GetActs.UNITCODE)>
						<CFIF sUnitCode2Use IS "">
							<CFSET sUnitCode2Use="PERSONNELIDNO">
						</CFIF>

						<!--- get intended recipients --->
						<CFQUERY NAME="GetRecipients" DATASOURCE="#client.global_dsn#">
							SELECT USERGRPMEMBERSIDX, GUID FROM EGRGROLEINDEX, EGRGUSERMASTER
							WHERE
								EGRGUSERMASTER.USERID = EGRGROLEINDEX.USERGRPMEMBERSIDX AND
								USERGRPID_FK = '#GetActs.ROLECODE#';
						</CFQUERY>

						<!--- if sole individual in role, SIYA NA! --->
						<CFIF GetRecipients.RecordCount EQ 1>
							<CFMODULE TEMPLATE="#client.common_path#cfm_getuser.cfm" USERID="#GetRecipients.USERGRPMEMBERSIDX#">
							<CFIF ISFOUND>
								<CFSET sIntentedRec = sIntentedRec & "(" & PERID & ") " & PERNAME & "<BR>">
							</CFIF>
						<CFELSE>
							<!--- if two or more recipients, extract one with same unitcode as originator --->
							<CFSET sValidActivityID=Replace(GetActs.ACTIVITYID, "-", "", "ALL")>
							<CFSET lUserRole="Yes">

								<CFQUERY NAME="overridemapping" DATASOURCE="#client.company_dsn#">
									SELECT *
									FROM ECMFUSRDEFINEROLE
									WHERE (ROUTEID = '#GETDATA.ROUTEID#') AND
										  (ACTIVITYID = '#GetActs.ACTIVITYID#')
								</CFQUERY>
							<CFQUERY NAME="getdivision" DATASOURCE="#client.company_dsn#">
								SELECT #sUnitCode2Use#
								FROM CMFPA
								WHERE PERSONNELIDNO = '#client.chapa#'
							</CFQUERY>
							<!--- by winston, pls chk, im nt sure... --->
							<!---added by jep--->
							<CFPARAM NAME="sCode2Use" DEFAULT="">
							<CFIF IsDefined("form.sel#sValidActivityID#")>
								<CFSET sCode2Use=Trim(Evaluate("form.sel#sValidActivityID#"))>
								<CFIF sCode2Use IS NOT "">
									<CFQUERY DATASOURCE="#client.global_dsn#" NAME="overridemapping">
										SELECT USERID
										FROM EGRGUSERMASTER
										WHERE GUID = '#sCode2Use#'
									</CFQUERY>
									<CFSET sCode2Use=overridemapping.USERID>
								</CFIF>
							<CFELSEIF lIsRouted>
								<CFSET sCode2Use=overridemapping.USERID>
							</CFIF>
							<CFIF sCode2Use EQ "">
								<CFSET sIntentedRec ="">
							<CFELSE>
								<CFMODULE TEMPLATE="#client.common_path#cfm_getuser.cfm" USERID="#sCode2Use#">
								<CFIF PERID NEQ "#CLIENT.CHAPA#">
									<CFSET sIntentedRec = sIntentedRec & "(" & PERID & ") " & PERNAME & "<BR>">
									<CFSET sPrevRcpt=PERID>
								<CFELSE>
									<CFSET sIntentedRec ="<FONT COLOR=red>Select approver. Originator should not be Approver.</FONT>">
									<CFSET lValidRoute  = False>
								</CFIF>
							</CFIF>
						</CFIF>
					</CFCASE>

					<!----------------------------------------------->
					<!--- the immediate superior is the recipient --->
					<!----------------------------------------------->
					<CFDEFAULTCASE> <!--- superior --->
						<!--- get superior code --->
						<CFQUERY NAME="GetCode" DATASOURCE="#client.company_dsn#">
							SELECT SUPERIORCODE, GUID, PERSONNELIDNO, LASTNAME #sqlCONCAT# ', ' #sqlCONCAT# FIRSTNAME #sqlCONCAT# ' ' #sqlCONCAT# MIDDLENAME AS NAME
							FROM CMFPA
							WHERE PERSONNELIDNO = '#sPrevRcpt#'
						</CFQUERY>

						<CFIF GetCode.RecordCount>
							<CFIF Trim(GetCode.SUPERIORCODE) NEQ "">
								<CFQUERY NAME="GetCode" DATASOURCE="#client.company_dsn#">
									SELECT GUID, PERSONNELIDNO, LASTNAME #sqlCONCAT# ', ' #sqlCONCAT# FIRSTNAME #sqlCONCAT# ' ' #sqlCONCAT# MIDDLENAME AS NAME
									FROM CMFPA
									WHERE PERSONNELIDNO = '#GetCode.SUPERIORCODE#'
								</CFQUERY>
							</CFIF>

							<!--- is superior a valid user --->
							<CFIF GetCode.RecordCount>
								<CFQUERY NAME="IsExists" DATASOURCE="#client.global_dsn#">
									SELECT USERID
									FROM EGRGUSERMASTER
									WHERE
										GUID = '#GetCode.GUID#'
								</CFQUERY>

								<CFIF IsExists.RecordCount>
									<CFSET sIntentedRec = "(" & GetCode.PERSONNELIDNO & ") " & GetCode.NAME>
									<CFSET sPrevRcpt=GetCode.PERSONNELIDNO>
								<CFELSE>
									<CFSET sIntentedRec = "<FONT COLOR=RED>Invalid! The recipient is not an iBOS/e Users.</FONT>">
									<CFSET lValidRoute  = False>
								</CFIF>
							</CFIF>
						</CFIF>
					</CFDEFAULTCASE>
				</CFSWITCH>

				<!--- ************************************************************* --->
				<!--- ************************************************************* --->
				<!--- ******    THE ROUTING PATH IS DEFINED AND EXTRACTED   ******* --->
				<!--- ******    THE PROCESS ENDS HERE                       ******* --->
				<!--- ************************************************************* --->
				<!--- ************************************************************* --->

				<!--- extract logs --->
				<!--- and action term made to be realistic... - winston--->
				<CFQUERY NAME="GetLog" DATASOURCE="#client.company_dsn#">
					SELECT A.*, C.STATUSDESC AS ACTIONMADE
					FROM CRGROUTEDETAILS A, CINFFACTIVITY B, CLKACTIONDETAILS C
					WHERE
						(A.STATUS = C.PROCESSINGACTION) AND
						(C.ACTIONCODE = B.ACTIONCODE) AND
						(A.ACTIVITYID = B.ACTIVITYID) AND
						(A.ACTIVITYID  = '#ACTIVITYID#') AND
						(A.ROUTEID     = '#GETDATA.ROUTEID#')
					ORDER BY A.CURRENTSEQUENCE, A.ROUTER, A.STATUS
				</CFQUERY>
				<CFSET theApprover="">
				<CFSETTING ENABLECFOUTPUTONLY="No">
<FORM METHOD="post" ACTION="#eform.sender#" NAME="Browse">
				<!--- scheduled activities --->
				<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH="100%">
					<TR>
						<TD NOWRAP>Sequence No.</TD>
						<TD CLASS="bold" WIDTH="100%">#ORDERID#</TD>
					</TR>
					<TR>
						<TD>Description&nbsp;</TD>
						<TD CLASS="bold">#DESCRIPTION#</TD>
					</TR>

					<input type="hidden" name="theApprover" value="">
					<TR VALIGN="top">
						<TD>Recipient/s</TD>
						<TD CLASS="bold">
							<CFIF sIntentedRec EQ "">
								<FONT COLOR="red">No intended recipient(s).</FONT>
								<CFSET lValidRoute  = False>
							<CFELSE>
								#sIntentedRec#
							</CFIF>
						</TD>
					</TR>
					<CFIF #len(trim(ACTIONCODE))# NEQ 0>
						<CFQUERY NAME="GetAction" DATASOURCE="#client.company_dsn#">
							SELECT DESCRIPTION
							FROM CLKACTIONS
							WHERE
								(ACTIONCODE = '#ACTIONCODE#')
						</CFQUERY>
					</CFIF>
					<!--- Added by Mhel --->
					<!--- Start --->
					<CFIF lUserRole AND NOT lIsRouted>
						<CFSET lHasUserRole="Yes">
						<CFSET lstGUID=quotedValuelist(GetRecipients.GUID, ',')>
						<CFIF lstGUID EQ "">
							<CFSET lstGUID="''">
						</CFIF>
						<CFQUERY NAME="getdivision" DATASOURCE="#client.company_dsn#">
							SELECT LASTNAME, FIRSTNAME, MIDDLENAME, GUID
							FROM CMFPA
							WHERE GUID IN (#preserveSingleQuotes(lstGUID)#)
							ORDER BY LASTNAME,FIRSTNAME,MIDDLENAME
						</CFQUERY>
						<cfset client.sCode2Use="#sCode2Use#">
						<input type="hidden" name="hidden#sValidActivityID#" value="#sCode2Use#">
						<tr>
							<td nowrap>Override Default Recipient:</td>
							<td><select name="sel#sValidActivityID#">
									<option value=" ">--Select new recipient--
									<CFLOOP QUERY="getdivision">
										<option value="#getdivision.GUID#">#getdivision.LASTNAME#, #getdivision.FIRSTNAME# #getdivision.MIDDLENAME#
									</CFLOOP>
								</select>
							</td>
						</tr>
					</CFIF>
					<!--- End --->
				</TABLE>
			</TD>
			<TD BGCOLOR="##808080"></TD>
			<TD WIDTH="50%">
			<CFLOOP QUERY="GetLog">
				<CFSET nAction = GetLog.CURRENTSEQUENCE - 1>
				<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0 WIDTH="100%">
					<TR><TD></TD><TD WIDTH="100%"></TD></TR>
					<TR>
						<TD>Status:</TD>
						<TD CLASS="bold">#GetLog.ACTIONMADE#</TD>
						<TD WIDTH="15" NOWRAP>Process No.:</TD>
						<TD CLASS="bold" WIDTH="10">#nAction#</TD>
					</TR>
					<TR>
						<TD VALIGN="top">Comments:</TD>
						<TD CLASS="bold" COLSPAN="3">#GetLog.ROUTERREMARKS#</TD>
					</TR>
					<TR>
						<TD>Source:</TD>
						<TD CLASS="bold" COLSPAN="3">#GetLog.ROUTER#</TD>
					</TR>
					<TR>
						<TD>Date/Time:</TD>
						<TD CLASS="bold" COLSPAN="3">
								#DayOfWeekAsString(DayOfWeek(GetLog.DATELASTUPDATE))#,&nbsp;
								#DateFormat(GetLog.DATELASTUPDATE, "mmmm d, yyyy")#&nbsp;
								#TimeFormat(GetLog.TIMELASTUPDATE, "hh:mmtt")#
						</TD>
					</TR>
					<CFIF FileExists(expandpath(client.image_path) & "signatures/" & GetLog.ROUTER & ".jpg")>
						<TR>
							<TD>Signature:</TD>
							<TD>
								<img src="#client.image_path#signatures/#GetLog.ROUTER#.jpg">
							</TD>
						</TR>
					</CFIF>
				</TABLE>
			</CFLOOP>
			</TD>
		</TR>
		<CFIF CurrentRow NEQ RecordCount>
			<TR><TD COLSPAN=3><HR></TD></TR>
		</CFIF>
		</CFOUTPUT>

		<!--- Added by Mhel --->
		<!--- Start --->
		<CFIF lHasUserRole>
			<CFSET sPKFields="">
			<CFLOOP LIST="#CLIENT.sufvalue#" index="i" delimiters="|">
			<CFIF Trim(GetForm.PK_FIELD1) IS NOT "">
				<CFSET sPKFields= sPKFields & "&" & "#listGetAt(i,1,'~')#">
				<CFIF Trim(GetForm.PK_FIELD2) IS NOT "">
					<CFSET sPKFields= sPKFields & "&" & "#listGetAt(i,2,'~')#">
					<CFIF Trim(GetForm.PK_FIELD3) IS NOT "">
						<CFSET sPKFields= sPKFields & "&" & "#listGetAt(i,3,'~')#">
						<CFIF Trim(GetForm.PK_FIELD4) IS NOT "">
							<CFSET sPKFields= sPKFields & "&" & "#listGetAt(i,4,'~')#">
							<CFIF Trim(GetForm.PK_FIELD5) IS NOT "">
								<CFSET sPKFields= sPKFields & "&" & "#listGetAt(i,5,'~')#">
							</CFIF>
						</CFIF>
					</CFIF>
				</CFIF>
			</CFIF>
			</CFLOOP>
			<tr><td colspan=3><HR></td></tr>
			<CFOUTPUT>
				<tr><td><input type="button" value="Update Form-Flow" onclick="UpdateFormFlow()"></td><td colspan=2></td></tr>
			</CFOUTPUT>
		</CFIF>
		<!--- End --->
	</TABLE>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">
	<CFSET appname = "Group Route " & GetForm.DESCRIPTION>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="#appname#">

	<CFOUTPUT>
	<CFIF sMess NEQ "">
		<B>#sMess#</B><BR>
	</CFIF>
	<CFIF sWarn NEQ "">
		<FONT COLOR="##FF0000"><B>#sWarn#</B></FONT><BR>
	</CFIF>
	<CFIF GetLevelID.LEVELID EQ "S">
		<cfset includeURLs="ID">
		<CFINCLUDE TEMPLATE="#client.common_path#cfm_selectsubcompanybar.cfm" >
	</CFIF>

	</CFOUTPUT>


	<!---
		required pre-set parameters:
			* eform.sender
			* eform.tablename
			* eform.field

		optional parameters:
			* eform.addnew
			* eform.char
			* eform.locator
	--->

	<!--- Set the number of records to display on each page. --->
	<CFIF NOT IsDefined("nOnEachPage")>
		<CFSET OnEachPage = 10>
	<CFELSE>
		<CFSET OnEachPage = nOnEachPage>
	</CFIF>

	<!--- first --->
	<CFIF isDefined("Form.First")>
		<CFSET form.startrow = 1>
	</CFIF>

	<CFIF	isDefined("Form.Prior")>
		<CFSET form.startrow = (form.startrow - OnEachPage)>
	</CFIF>

	<CFIF	isDefined("Form.Next")>
		<CFSET form.startrow = (form.startrow + OnEachPage)>
	</CFIF>

	<CFIF	isDefined("Form.Last")>
		<CFSET form.startrow = (GetData.RecordCount - (GetData.RecordCount MOD OnEachPage)) + 1>
		<CFIF  form.startrow GT GetData.RecordCount>
			<CFSET form.startrow = (GetData.RecordCount - OnEachPage) + 1>
		</CFIF>
	</CFIF>



	<!--- get the last rows to be displayed --->
	<CFSET LastRow = (GetData.RecordCount - (GetData.RecordCount MOD OnEachPage)) + 1>
	<CFIF LastRow GT GetData.RecordCount>
		<CFSET LastRow = (GetData.RecordCount - OnEachPage) + 1>
	</CFIF>

	<!--- Set the value of endrow to the maxrows + startrow - 1 --->
	<CFSET EndRow = form.startrow + OnEachPage - 1>

	<!--- If the end row is greater than the recordcount, determine how many records are left. --->
	<CFIF EndRow GTE GetData.RecordCount>
		<CFSET EndRow = GetData.RecordCount>
		<CFSET Next = false>

	<!--- Othereise, set Next to true and determine the next set of records. --->
	<CFELSE>
		<CFSET Next = true>
		<CFIF EndRow + OnEachPage GT GetData.RecordCount>
			<CFSET NextNum = GetData.RecordCount - EndRow>
		<CFELSE>
			<CFSET NextNum =  OnEachPage>
		</CFIF>
		<CFSET NextStart = EndRow + 1>
	</CFIF>

	<!--- If StartRow is 1, set Previous to false. --->
	<CFIF form.startrow IS 1>
		<CFSET Previous = false>

	<!--- Othewise, determine the previous set of records. --->
	<CFELSE>
		<CFSET Previous = true>
		<CFSET PreviousStart = form.startrow - OnEachPage>
	</CFIF>
	<!--- Create custom function for left mssql statement, work around for oracle and other db w/o left statement.
	Note: first workaround is to use substring function but this does not work on date fields,
	thus resulting to custom left function--->
	<CFMODULE TEMPLATE="#client.common_path#cfm_sqlleftfunc.cfm" field="#eform.field#" numchars=1>
	<CFSET sSQL = sqlstmt>
	<!--- extract all unique items --->
	<CFQUERY name="GetFirst" datasource="#table_dsn#">
		SELECT DISTINCT #sSQL# AS FIRSTCHAR
		FROM #eform.tablename#
		WHERE (PERSONNELIDNO = '#GetEmployee.PERSONNELIDNO#')
		ORDER BY FIRSTCHAR
	</CFQUERY>

	<CFOUTPUT>
	<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=3 BGCOLOR="#client.color_grphead#" WIDTH="100%">
	</CFOUTPUT>

		<TR>
			<CFOUTPUT>
			<TD NOWRAP  CLASS="white">
				<INPUT TYPE="submit" NAME="btnGrpRoute" VALUE="Route" CLASS="bitbtn" DISABLED>
				&nbsp;Include eForm:<input type="radio" name="rdoIncludeForm" value="Y">Yes
				<input type="radio" name="rdoIncludeForm" value="N" checked>No
				&nbsp;&nbsp;&nbsp;&nbsp;Priority:&nbsp;
				<SELECT CLASS="regular11" NAME="cmbPriority"
					<OPTION VALUE="1">&nbsp;High
					<OPTION VALUE="2" SELECTED>&nbsp;Normal&nbsp;
					<OPTION VALUE="3">&nbsp;Low
				</SELECT>
			</TD>
			</CFOUTPUT>
			<!--- for sorting records --->
			<!---
			<CFOUTPUT>
			<TD NOWRAP ALIGN="right" CLASS="white">
				&nbsp;Sort:&nbsp;
				<SELECT NAME="cmbSort" SIZE="1" CLASS="bitbtn">
					<CFLOOP INDEX="x" FROM=1 TO=#arraylen(eform.fieldsarray)#>
						<CFIF eform.field IS "#eform.fieldsarray[x][1]#">
							<OPTION SELECTED VALUE="#eform.fieldsarray[x][1]#">&nbsp;#eform.fieldsarray[x][2]#</OPTION>
						<CFELSE>
							<OPTION VALUE="#eform.fieldsarray[x][1]#">&nbsp;#eform.fieldsarray[x][2]#</OPTION>
						</CFIF>
					</CFLOOP>
				</SELECT>
				<select name="selAscDesc" class="bitbtn">
					<option selected value="asc">Ascending
					<option <CFIF eform.ascdesc IS "desc">selected</CFIF> value="desc">Descending
				</select>
				<INPUT TYPE="submit" TITLE="Sort Now" VALUE="Sort" NAME="Sort" CLASS="bitbtn">&nbsp;
				</CFOUTPUT>


				&nbsp;Filter:&nbsp;
				<SELECT NAME="cmbFilter" SIZE="1" CLASS="bitbtn">
					<CFIF eform.char EQ "">
						<OPTION SELECTED VALUE="all">&nbsp;All Items&nbsp;</OPTION>
					<CFELSE>
						<OPTION SELECTED VALUE="all">&nbsp;All Items&nbsp;</OPTION>
					</CFIF>

					<CFOUTPUT QUERY="GetFirst">
						<CFIF eform.char IS "#FIRSTCHAR#">
							<OPTION VALUE="#FIRSTCHAR#" SELECTED>&nbsp;#ucase(FIRSTCHAR)#</OPTION>
						<CFELSE>
							<OPTION VALUE="#FIRSTCHAR#">&nbsp;#ucase(FIRSTCHAR)#</OPTION>
						</CFIF>
					</CFOUTPUT>
				</SELECT>

				<CFOUTPUT>
				<INPUT TYPE="text" NAME="edtValFilter" SIZE="8" CLASS="toolbar" VALUE="#eform.locator#">
				<INPUT TYPE="submit" TITLE="Apply Filter" NAME="Filter" CLASS="bitbtn" VALUE="Filter">&nbsp;
				</CFOUTPUT>
			</TD>
		</TR>
	</TABLE>
	--->
	<CFSET lFirstLoop=true>

	<!--- to browse on records --->
	<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=0 WIDTH="100%">
		<CFIF NOT GetData.RecordCount>
			<TR><TD CLASS="bold"><BR>No records found in the current filter.</TD></TR>
		<CFELSE>
			<CFOUTPUT>

			<TR bgcolor="#client.color_tblhead#">
				<TD></TD>
				<TD></TD>
				<CFIF GetFormDetails.RecordCount>
					<TD></TD>
				</CFIF>

				<CFSET iBrowseCtr = 0>
				<CFLOOP INDEX="x" FROM=1 TO="#arrayLen(arrFields)#">
					<CFIF #lcase(arrFields[x][4])# NEQ "y">
						<CFSET iBrowseCtr = iBrowseCtr + 1>
						<TD class="boldwhite" HEIGHT=18>&nbsp;#arrFields[x][2]#</TD>
					</CFIF>
				</CFLOOP>
			</TR>
			</CFOUTPUT>
			<!--- Get URL fields --->
			<CFSET sUrlFields = "">
			<CFLOOP INDEX="x" FROM="1" TO="5">
				<CFSET strPk_Field = evaluate("GetForm.PK_FIELD" & x)>
				<CFIF strPk_Field NEQ "" AND listFindNoCase(sUrlFields,strPk_Field) EQ 0>
					<CFSET sUrlFields = listAppend(sUrlFields,strPk_Field)>
				</CFIF>
			</CFLOOP>
			<CFLOOP QUERY="GetFormDetails">
				<CFLOOP INDEX="x" FROM="1" TO="5">
					<CFSET strLnk_Field = evaluate("GetFormDetails.LNK_FIELD" & x)>
					<CFIF strLnk_Field NEQ "" AND listFindNoCase(sUrlFields,strLnk_Field) EQ 0>
						<CFSET sUrlFields = listAppend(sUrlFields,strLnk_Field)>
					</CFIF>
				</CFLOOP>
			</CFLOOP>
			<!--- Get URL fields End--->
			<CFOUTPUT QUERY="GetData" StartRow="#form.startrow#" MaxRows="#OnEachPage#">
				<TR BGCOLOR=<CFIF CurrentRow Mod 2>"#client.color_tblset2#"<CFELSE>"#client.color_tblset1#"</CFIF> VALIGN="top">

					<!--- get the values of the indexed fields --->
					<CFSET sUFValue = "">
					<CFSET sUFValue2 = "">
					<CFSET sFieldsValue = "">
					<CFSET FIRST=TRUE>
					<CFLOOP LIST="#sUrlFields#" INDEX="x">
						<CFIF x NEQ "PERSONNELIDNO">
							<CFIF FIRST>
								<CFSET sUFValue = sUFValue & "&" & x & "=" & evaluate("GetData." & x)>
								<CFSET sUFValue2 = sUFValue2 & x & "='" & evaluate("GetData." & x) & "'">
								<CFSET FIRST=FALSE>
							<CFELSE>
								<CFSET sUFValue = sUFValue & "~" & x & "=" & evaluate("GetData." & x)>
								<CFSET sUFValue2 = sUFValue2 & x & "='" & evaluate("GetData." & x) & "'">
							</CFIF>
						</CFIF>
					</CFLOOP>

					<CFIF lFirstLoop>
						<CFSET lFirstLoop=false>
						<CFSET sDefault1="#sTypeID##sUFValue2#">
						<CFSET sDefault2="#CurrentRow#">
					</CFIF>

					<TD NOWRAP CLASS="regular11">
						<CFIF lLoadContainer>
							<CFIF CurrentRow Mod 2>
								<CFSET theColor = client.color_tblset2>
							<CFELSE>
								<CFSET theColor = client.color_tblset1>
							</CFIF>
							<li id="li#CurrentRow#" style="color: #theColor#" gridcolor="#theColor#"></li>
						</CFIF>
						<INPUT TYPE="CHECKBOX" NAME="chkAction" VALUE="#sUFValue2#" ONCLICK="javascript:checkSelected();">
					</TD>
					<TD>
						<CFIF lcase(accessEdit) EQ "y" OR lcase(accessView) EQ "y">
							&nbsp;
							<CFSET appname = GetForm.DESCRIPTION & " [View Details]">
							<A CLASS="regular11" HREF="#eform.sender##sUFValue#&view=">view</A>
						</CFIF>

					</TD>




					<CFLOOP INDEX="x" FROM=1 TO="#arrayLen(arrFields)#">
						<CFIF #lcase(arrFields[x][4])# NEQ "y">
							<CFSET sValue = #evaluate(arrFields[x][1])#>
							<CFSWITCH EXPRESSION="#lcase(arrFields[x][3])#">
								<CFCASE VALUE="ftdatetime">
								<TD NOWRAP HEIGHT=17>
									<CFIF sValue EQ "01/01/1900">
										&nbsp;
									<CFELSE>
										&nbsp;#DateFormat(sValue, "mmm-dd-yy")#
									</CFIF>
								</TD>
								</CFCASE>
								<CFCASE VALUE="ftfloat">
								<!--- Added by Mhel --->
								<!--- Start --->
								<CFSET sDecFormat=ToString(DecimalFormat(val(sValue)))>
								<CFIF Right(sDecFormat, 3) IS ".00">
									<CFSET sDecFormat=Replace(sDecFormat, ".00", "")>
								</CFIF>
								<!--- End --->
			    	  		<TD NOWRAP HEIGHT=17 ALIGN="right">
										&nbsp;#sDecFormat#
									</TD>
								</CFCASE>
								<CFCASE VALUE="ftinteger">
			    	  		<TD NOWRAP HEIGHT=17 ALIGN="right">
										&nbsp;#sValue#
									</TD>
								</CFCASE>
								<CFCASE VALUE="ftblob,ftgraphic">
						<TD NOWRAP HEIGHT=17 ALIGN="right">&nbsp;</TD>
								</CFCASE>

								<CFDEFAULTCASE>
			    	  		<TD HEIGHT=17>
										&nbsp;#sValue#
									</TD>
								</CFDEFAULTCASE>
							</CFSWITCH>
						</CFIF>
					</CFLOOP>
			  </TR>
			</CFOUTPUT>

			<CFOUTPUT>

			    <CFIF GetFormDetails.RecordCount>
					<CFSET iBrowseCtr = iBrowseCtr+2>
				<CFELSE>
					<CFSET iBrowseCtr = iBrowseCtr+1>
				</CFIF>

				<TR bgcolor="#client.color_tblfoot#">
					<TD class="white" HEIGHT=18 COLSPAN="#iBrowseCtr#">
						&nbsp;
						Records: <B>#form.startrow#-#EndRow#</B>
						&nbsp;of&nbsp;
						<B>#GetData.RecordCount#</B>
					</TD>
					<TD></TD>
				</TR>
			</CFOUTPUT>
		</CFIF>
	</TABLE>
	</FORM>
	<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">

	<CFIF lLoadContainer>
		<!--- Added by Mhel for master-detail --->
		<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TITLE="Details">
		<TABLE BORDER=0 CELLPADDING=5 CELLSPACING=0 WIDTH="100%">
		<CFOUTPUT>
		<TR>
			<TD ALIGN="right"><IMG SRC="#client.image_path##session.site_ibose#"></TD>
			<TD NOWRAP CLASS="bold14" WIDTH="100%"><FONT FACE="Impact" SIZE="+2">#client.companyname#</FONT><BR>#GetForm.DESCRIPTION#</TD>
		</TR>
		</CFOUTPUT>
		</TABLE>

		<form name="frmDetails">
		<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2 WIDTH="100%" BGCOLOR="#FFFFFF">
		<CFOUTPUT QUERY="GetFields" GROUP="FIELDGROUP">
			<CFIF len(trim(FIELDGROUP)) NEQ 0>
				<TR>
					<TD CLASS="bold11" BGCOLOR="#client.color_tblset2#" COLSPAN=3>
						&nbsp;#FIELDGROUP# #HINT#
					</TD>
				</TR>
			</CFIF>

			<CFOUTPUT>
			<TR VALIGN="top">
				<TD NOWRAP VALIGN="top" ALIGN="right">#COLUMNDESC#:</TD>
				<TD VALIGN="top" WIDTH="100%" HEIGHT=18 nowrap>&nbsp;
				<!--- check on what form control to use --->
				<CFSWITCH EXPRESSION="#lcase(COLUMNTYPE)#">

				<!--- calculator lookup --->
			    <CFCASE VALUE="ftinteger,ftfloat,ftdatetime">
					<input class="regular11" type="text" readonly name="#COLUMNNAME#" style="border: none;" SIZE="20">
				</CFCASE>

				<!--- memo fields --->
			    <CFCASE VALUE="ftmemo">
					<TEXTAREA class="regular11" ROWS="3" COLS="#DISPLAYWIDTH#" readonly name="#COLUMNNAME#" style="background-color: transparent; border: none; font-weight: bold; width: 99%;"></TEXTAREA>
				</CFCASE>

				<CFDEFAULTCASE>
					<CFSET sLkUpDescLength=PHYSICALWIDTH + 5>

					<!--- get lookup info --->
					<CFQUERY NAME="GetLookup" DATASOURCE="#client.global_dsn#">
							SELECT A.*, B.LEVELID
							FROM GSTLOOKUP A, GRGBOSETABLE B
							WHERE
								(A.MASTERTABLE = '#GetForm.TABLENAME_FK#') AND
								(A.MASTERFIELD = '#COLUMNNAME#') AND
								(A.LOOKUPTABLE = B.TABLENAME)
					</CFQUERY>
					<CFIF GetLookup.RecordCount>
						<CFIF (#trim(GetLookup.LEVELID)# NEQ "") AND
								(#trim(GetLookup.LOOKUPKEYFIELD)# NEQ "") AND
								(#trim(GetLookup.LOOKUPRESULTFIELD)# NEQ "") AND
								(#trim(GetLookup.LOOKUPTABLE)# NEQ "")>
							<!--- get the length of description --->
							<CFQUERY NAME="qryDescLength" DATASOURCE=#client.global_dsn#>
								SELECT PHYSICALWIDTH
								FROM GRGBOSETABLEFIELDS
								WHERE TABLENAME = '#GetLookup.LOOKUPTABLE#' AND
									  COLUMNNAME = '#GetLookup.LOOKUPRESULTFIELD#'
							</CFQUERY>

							<CFIF qryDescLength.PHYSICALWIDTH NEQ "" AND
									qryDescLength.PHYSICALWIDTH NEQ 0>
								<CFSET sLkUpDescLength=sLkUpDescLength + qryDescLength.PHYSICALWIDTH + 5>
							<CFELSE>
								<CFSET sLkUpDescLength=sLkUpDescLength + 50>
							</CFIF>

							<!--- for chart --->
							<CFIF LCase(ISORGCHART) IS "y">
								<A HREF="javascript:ShowChart('#Trim(GetLookup.LEVELID)#','#Trim(GetLookup.LOOKUPTABLE)#','#Trim(GetLookup.LOOKUPKEYFIELD)#','#Trim(GetLookup.LOOKUPRESULTFIELD)#','hid#COLUMNNAME#','frmDetails','#COLUMNDESC#')">show chart</A>&nbsp;&nbsp;
								<input type="hidden" name="hid#COLUMNNAME#">
							</CFIF>
						</CFIF>
					</CFIF>

					<input class="regular11" type="text" readonly name="#COLUMNNAME#" style="border: none;" SIZE="#sLkUpDescLength#">
				</CFDEFAULTCASE>
				</CFSWITCH>
				</TD>
			</TR>

			<!--- For extra desc in lookup --->
			<CFQUERY NAME="GetLookup" DATASOURCE=#client.global_dsn#>
					SELECT A.*, B.LEVELID
					FROM GSTLOOKUP A, GRGBOSETABLE B
					WHERE (A.MASTERTABLE = '#GetForm.TABLENAME_FK#') AND
						  (A.MASTERFIELD = '#COLUMNNAME#') AND
						  (A.LOOKUPTABLE = B.TABLENAME)
			</CFQUERY>

			<CFIF (GetLookup.RecordCount) AND trim(GetLookup.EXTRARESULTFLD) NEQ "">
				<!--- Get the description and datatype of display fields for lookup --->
				<CFSET sComma="">
				<CFQUERY NAME="qryDispLkUp" DATASOURCE=#client.global_dsn#>
					SELECT COLUMNNAME, COLUMNDESC, COLUMNTYPE, PHYSICALWIDTH, DISPLAYWIDTH
					FROM GRGBOSETABLEFIELDS
					WHERE (TABLENAME = '#Trim(GetLookup.LOOKUPTABLE)#') AND
						  (
						  	COLUMNNAME IN (
					  	<CFLOOP LIST="#GetLookup.EXTRARESULTFLD#" INDEX="x">
							#sComma# '#Trim(x)#'
							<CFSET sComma=",">
						</CFLOOP>
						  )
						  )
				</CFQUERY>
				<CFSET lstKeyValue=Valuelist(qryDispLkUp.COLUMNNAME)>

				<CFLOOP LIST="#GetLookup.EXTRARESULTFLD#" INDEX="x">
					<CFSET x = trim(x)>
					<TR VALIGN="top">

						<CFSET nPos=ListFindNocase(#lstKeyValue#, #x#)>
						<CFIF nPos NEQ 0>
							<CFSET sColDesc=#qryDispLkUp.COLUMNDESC[nPos]#>
							<CFSET sDataType=#qryDispLkUp.COLUMNTYPE[nPos]#>
							<CFSET sPhysicalWidth=#qryDispLkUp.PHYSICALWIDTH[nPos]#>
							<CFSET sDisplayWidth=#qryDispLkUp.DISPLAYWIDTH[nPos]#>
						<CFELSE>
							<CFSET sColDesc="">
							<CFSET sDataType="">
							<CFSET sPhysicalWidth="75">
							<CFSET sDisplayWidth="20">
						</CFIF>

						<CFIF NOT ListFindNoCase(sFields,#x#)>
						<TD NOWRAP VALIGN="top" ALIGN="right">#sColDesc#:</TD>
						<TD VALIGN="top" WIDTH="100%" HEIGHT=18 nowrap>&nbsp;<B>
							<CFSWITCH EXPRESSION="#lcase(sDataType)#">

							<!--- calculator lookup --->
						    <CFCASE VALUE="ftinteger,ftfloat,ftdatetime">
								<input class="regular11" type="text" readonly name="#x#" style="border: none;" SIZE="20">
							</CFCASE>

							<!--- memo fields --->
						    <CFCASE VALUE="ftmemo">
								<TEXTAREA class="regular11" ROWS="3" COLS="#sDisplayWidth#" readonly name="#x#" style="background-color: transparent; border: none; font-weight: bold;"></TEXTAREA>
							</CFCASE>

							<CFDEFAULTCASE>
								<input class="regular11" type="text" readonly name="#x#" style="border: none;" size=#sPhysicalWidth# + 5>
							</CFDEFAULTCASE>
							</CFSWITCH>
						</TD>
						</CFIF>
					</TR>
				</CFLOOP>
			</CFIF>
			</CFOUTPUT>
		</CFOUTPUT>
		</form>
		</TABLE>

		<CFMODULE TEMPLATE="#client.common_path#cfm_wswindow.cfm" TOP="False">

		<script>
		var eFormHandle, sCurrentID

		<CFOUTPUT>
			<CFIF NOT lFirstLoop>
				LoadContainer("#sDefault1#", "#sDefault2#")
			</CFIF>
		</CFOUTPUT>
		function LoadContainer(sParam, sID) {
		var sValue=(typeof eFormHandle)

			if ((typeof sCurrentID) != "undefined")
				eval("document.all.li" + sCurrentID).style.color=eval("document.all.li" + sCurrentID).gridcolor

			eval("document.all.li" + sID).style.color="black"
			sCurrentID=sID

			<CFOUTPUT>
			if (sValue == "undefined")
				eFormHandle=open("detailpacket.cfm?id=" + sParam, "eformperid#session.sessionid#", "width=10,height=10,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes")
			else
				eFormHandle=open("detailpacket.cfm?id=" + sParam, "eformperid#session.sessionid#", "width=10,height=10,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes")
			</CFOUTPUT>

			if (sValue == "undefined")
				eFormHandle.moveTo(eFormHandle.screen.availWidth,eFormHandle.screen.availHeight)
		}

		</script>
	</CFIF>